/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.matrimonyapp;

import com.matrimonybeans.PaymentLocal;
import com.matrimonybeans.UpdatePaymentLocal;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;

import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Date;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author 4410s
 */
public class Update_Payment extends HttpServlet {
    @EJB
    private UpdatePaymentLocal updatePayment;
 
    
    

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        
        int id_deser=Integer.parseInt(request.getParameter("txt_id"));
        int id_services=Integer.parseInt(request.getParameter("txt_idservices"));
        String  username=request.getParameter("txt_username");
       
        
        String user_admin=request.getParameter("txt_useradmin");
        String car_types=request.getParameter("txt_cartypes");
        String car_number=request.getParameter("txt_carnumber");
        String status=request.getParameter("drop_status");
                
        try {
           
         if(updatePayment.Update_Payment_Data(id_services,username,car_types,car_number,status,user_admin,id_deser))
         {
             out.println("Update Sucessfull");
             response.sendRedirect("View_Payment_Data");
          }else
         {
             out.println("Update Error");
             
         }
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}